package com.yl.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yl.model.Orders;
import com.yl.service.IOrdersService;
import com.yl.service.IUsersService;
@ResponseBody
@Controller
public class OrdersController {

	
	@Resource
	private IOrdersService ordersService;
	@Resource
	private IUsersService usersService;
	//前台新增订单
	@RequestMapping("/addorders.do")
	public int add(Orders orders) {	
		//将用户默认地址设为订单收获地址
				int address_id = usersService.findAddressId(orders.getUser_id());
				orders.setAddress_id(address_id);
				ordersService.add(orders);//返回的主键已经回传到请求参数的id属性中
				return orders.getOrders_id();
		
	}
	
	
}
